<!DOCTYPE html>
<html ng-app='yhcYxDtPage'>

<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="x-rim-auto-match" content="none">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
    <link rel="stylesheet" type="text/css" href="./css/reset.css">
    <link rel="stylesheet" type="text/css" href="./stylesheets/main.css">
    <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">-->
    <title>赢火虫答题有奖闹元宵</title>
</head>

<body ng-controller='bodyCtrl'>
    <div id="container">
        <!--显示进度条-->
        <div class="progress" ng-show="!showProgress">
            <div class="progress-bar" ng-style="proStyle" >
                <span>{{proInt}}%<s></s></span>

            </div>
        </div>
        <div class='wrapper' ng-style="wrapperStyle" ng-class="{show: showFirstPaqge}">
            <audio id="audio" src="audio/nyx.mp3"></audio>
            <div class="music-play" ng-click="stopMusic()" ng-class="{stop: isStop}">
              <span class="music1"><s></s></span>
              <span class="music2"><s></s></span>
              <span class="music3"><s></s></span>
            </div>
            <div class="firstPage" ng-show="showHomePage">
                <img src="./img/index_top.png" class="top_img"></img>
                <div class="logo_img">
                    <img src="./img/index_logo.png"></img>
                </div>
                <div class="rankList">
                    <s class="lantern"></s>
                    <div class="rankNameList">
                        <ul>
                            <li ng-repeat="data in rankingList track by $index">
                                <div class="pm">
                                    <img src="./img/index_no1.png" width="27px" ng-show="$index==0"/>
                                    <img src="./img/index_no2.png" width="27px" ng-show="$index==1"/>
                                    <img src="./img/index_no3.png" width="27px" ng-show="$index==2"/>
                                </div>
                                <div class="tx">
                                    <img ng-src="{{data.avatarUrl}}" width="20px"/>
                                </div>
                                <span class="nickName" ng-bind="data.nickName">从今、以后</span>
                                <span>{{data.answerTime}}'</span>
                            </li>

                        </ul>
                    </div>
                </div>
                <div class="startBtn" ng-click="showQuestionPage()">
                    <img src="./img/index_btn1.png"></img>
                    <s class="lantern"></s>
                </div>
                <div class="ruleBtn" ng-click="showRuleDiv()">
                    <img src="./img/index_btn2.png"></img>
                </div>
            </div>
            <div id="answerQuestions" ng-show="showQuestionPage" >
                <div class="head">
                    <img src="img/answerQuestions_head.png" style="width: 100%;">
                    <div class="time">
                        <div style="display: inline-block;position: relative">
                            倒计时：<span id="time_min">03</span>:<span id="time_sec">00</span>
                            <div style="position: absolute;top:-15px;right: -25px;" ng-show="showErr5" class="showErr5">
                                <img src="img/time_end.png" style="width: 20px;height: 15px;">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="question">
                    <img src="img/answerQuestions_door.png" style="width: 100%">
                    <s class="lantern"></s>
                    <s class="lantern2"></s>
                    <div class="con">
                        <div style="font-size: 18px;line-height: 26px;" ng-bind="question"></div>
                        <div style="font-size: 14px;line-height: 22px;" ng-bind="questionTip"></div>
                    </div>
                    <div class="sucNum" style="font-size: 14px;line-height: 20px;">
                        您已答对<span style="font-size: 20px;color: #fc0017;padding: 0 5px;" ng-bind="trueNum"></span>题
                    </div>
                </div>
                <div class="answer">
                    <div class="con" ng-class="classAns1" ng-bind="answer1" ng-click="checkAns(1,answer1)"></div>
                    <div class="con" ng-class="classAns2" ng-bind="answer2" ng-click="checkAns(2,answer2)"></div>
                    <div class="con" ng-class="classAns3" ng-bind="answer3" ng-click="checkAns(3,answer3)"></div>
                    <div class="con" ng-class="classAns4" ng-bind="answer4" ng-click="checkAns(4,answer4)"></div>
                </div>
            </div>
            <div ng-show="loser" id="loser">
                <div style="position: relative;">
                    <img src="img/answerQuestions_loser1.png" style="width: 100%">
                    <img src="./img/del.png" style="width: 37px;position: absolute;top: -40px;right: 45px;" ng-click="closeTimeOver()"/>
                </div>

                <img src="img/answerQuestions_loser2.png" ng-click="again()" style="width: 150px;margin-top: 10px">
            </div>
            <div id="results" ng-show="showResultsPage">
                <img src="img/end_top.png" style="width: 100%">
                <div class="con">
                    <div class="avatar">
                        <div><img ng-src="{{userData.avatar}}" style="border-radius: 50%;width:66px;"></img></div>
                    </div>
                    <div style="font-size: 24px;line-height: 40px">您被评为本次大会</div>
                    <div style="font-size: 46px;line-height: 70px" id="results_lever">灯谜大师</div>
                    <div style="font-size: 20px;line-height: 30px;text-align: center" id="results_des">
                        灯谜界的王者，<br>荣耀于天地，<br>请收下我们的膝盖！
                    </div>
                    <div style="font-size: 18px;line-height: 20px;padding-top:20px;">您当前的排名是：{{rankNow}}</div>
                    <div class="again" style="width: 51px;height: 37px;">
                        <img src="img/end_again.png" style="width: 51px;height: 37px;">
                    </div>
                </div>
                <div class="tip">注：最终获奖名单将于3月5日10时在赢火虫微信公众号公布，敬请期待！</div>
                <div class="foot">
                    <img src="img/end_btn1.png" alt="" ng-click="showgAttentionPage()">
                    <img src="img/end_btn2.png" alt="" ng-click="showShareQuanPage()">
                </div>
            </div>
            <div class="shareQuanPage" ng-style="wrapperStyle" id="myCanvas" ng-class="{show: sharePyQuanPage}">
                <div class="topUserInfo">
                    <div class="avatarUrl">
                        <img ng-src="{{userData.avatar}}"/>
                    </div>
                    <p ng-bind="userData.nickName">从今以后</p>
                </div>
                <div class="pinjia">
                    <p class="pj_title">在全球灯谜大会中被评为</p>
                    <div class="pjDes">
                        <p class="des_one" id="share_lever">灯谜王者</p>
                        <div class="pjDesDown" id="share_des">
                            <!--<p>灯谜界的王者，</p>-->
                            <!--<p>荣耀与天地，</p>-->
                            <!--<p>请收下我们的膝盖。</p>-->
                            {{shareQuanData[1]}}
                        </div>
                    </div>
                </div>
                <div class="shareFoot" >
                    <img src="./img/share_foot.png" class="shareBt"></img>
                    <img src="./img/share_ewm.png" class="ewm"></img>
                </div>
            </div>
        </div>
        <!--游戏规则页面-->
        <div class="globalGameRule" ng-class="{show: showGameRuleDiv}">
            <div class="rule_bg bounceInUpAni">
                <img src="./img/game_rules.png" class="rule_bg"></img>
                <img src="./img/del.png" class="rule_del" ng-click="closeGameRule()"></img>
                <div class="ruleContent">
                    <p>1.  游戏开始，在灯谜下方选择您认为的正确答案，累计答对十道题，用时越短，则有机会冲击排行榜，答错一题扣5秒，时间限制180秒；</p>
                    <p>2.  活动期间，用户可以选择重新玩，游戏次数不限，累计答对十道题之后可知自己排名；</p>
                    <p>3.  只有进入排行榜后才可获得相应奖励，排行榜只计用户最好成绩加入排名；</p>
                    <p class="bt">游戏奖励：</p>
                    <p>1.  活动期间（2018.3.2-3.5），排行榜结算至2018.3.5日10点00分前成绩，按答题累计时间排名，选取前60名发放奖品，奖品如下：</p>
                    <div class="ruleTb">
                        <table border="1">
                            <tr>
                                <td>名次</td>
                                <td>奖励</td>
                            </tr>
                            <tr>
                                <td>第1名</td>
                                <td>500元手机话费</td>
                            </tr>
                            <tr>
                                <td>2-5名</td>
                                <td>50元手机话费</td>
                            </tr>
                            <tr>
                                <td>6-20名</td>
                                <td>30元手机话费</td>
                            </tr>
                            <tr>
                                <td>21-60名</td>
                                <td>10元手机话费</td>
                            </tr>
                        </table>
                    </div>
                    <p>2.  领取奖励，请答完题后，扫描下方二维码，关注“赢火虫诉讼投资机构”公众号，等待客服与您联系哦。</p>
                </div>
            </div>
        </div>
        <!--关注页面-->
        <div class="globalAttention" ng-class="{show: showGlobalAttention}">
            <div class="showInfo" ng-class="{show: isShowAmi}">
                <div class="content">
                    <div style="margin-top: 20px;">
                        <img src="./img/share_ewm.png" style="width: 80px;"></img>
                    </div>
                    <div style="margin-top: 10px;">
                        <img src="./img/share_text1.png" style="width: 192px;"></img>
                    </div>
                    <div style="margin-top: 15px;">
                        <img src="./img/share_text2.png" style="width: 316px;"></img>
                    </div>
                    <img src="./img/end_del.png" style="position: absolute; top: -10px;right: 15px;width: 15px;" ng-click="closeGuanZhu()"></img>
                </div>

            </div>
        </div>
        <!--生成图片loading层-->
        <div class='createPicLoading' ng-class="{show: showLoading}">
            <p>正在生成...</p>
        </div>
        <!--提示不是微信环境-->
        <div class="tipWeiXinEnv" ng-class="{show: showTipWeiXinEnv}">
            <div class="info-dialog-box">
                <div class="info-content">请在微信里打开!</div>
                <div class="info-btn">
                    <a style="color:#36ADF9" class="info-btn-cancel" ng-click="closeTipWeiXinEnv()">知道了</a>
                </div>
            </div>
        </div>
        <!--生成分享的图片-->
        <div class="share-poster-result-dialog" ng-class="{show: showQuanShare}">
            <div class="dialog-content bounceInUpAni" >
                <div class="dialog-close" ng-click="closeShareQuan()"></div>
                <div class="dialog-top">长按图片保存海报分享朋友圈</div>
                <div class="dialog-content-container">
                    <div style="width:100%;"><img id="share_poster_img" ng-src="{{shareQuanImg}}" width="100%" ></div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="//wximg.qq.com/wxp/libs/wxmoment/0.0.4/wxmoment.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/html2canvas.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/angular.min.js"></script>
<script src="js/jweixin-1.2.0.js"></script>
<script src="https://apps.bdimg.com/libs/angular-route/1.3.13/angular-route.js"></script>
<script type="text/javascript">
var app = angular.module("yhcYxDtPage", ['ngRoute']);
app.controller('bodyCtrl', function($scope, $timeout, $interval, $http,$location) {
    $scope.showQuestionPage = false;
    $scope.showResultsPage = false;
    var audio = $("#audio")[0];
    var dev = "dev";
    var requestUrl = 'http://10.1.10.142:9095';
    if(dev == 'prd'){

    }else{
        requestUrl ='';
    }


    // var userData ={
    //     openid: "b5W7PvKImTAZn1Mp0NWk",
    //     nickName: "从今以后",
    //     avatar:"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTIv884WelTAsYmuOjToiaqicgAsGE3wOS9d3KKicTKD2ywjBe3FZGkEd6elE9DrGHCacU13JJj7zrsDQ/0"
    // };
    var userData ={
        openid: "",
        nickName: "",
        avatar:""
    };

    //进度条开始***********************************************//
    $scope.proInt = 0;
    $scope.proStyle = {
        "width":"0%"
    }
    var programInterval = $interval(function () {
        if($scope.proInt == 100){
            $interval.cancel(programInterval);
            $timeout(function(){
                $scope.showProgress = true;
                $scope.showFirstPaqge = true;
                $scope.showHomePage = true;
                audio.play();
                console.log("userData===",userData)
                getHttpData();
            },500);
        }else{
            $scope.proInt++
            $scope.proStyle = {
                "width":$scope.proInt+"%"
            }
        }
    },30);
    //进度条结束*********************************************************************************//

    //点击暂停播放音乐
    $scope.stopMusic = function() {
        if ($scope.isStop){
            $scope.isStop = false;
            audio.play();
        }else{
            $scope.isStop = true;
            audio.pause();
        }

    }

    //点击生成图片
    $scope.createPic = function () {
        $scope.showLoading = true;
        $scope.showMyCanvas = true;
        $timeout(function () {
            html2canvas($("#myCanvas"), {
                onrendered: function(canvas) {
                    $('#down_button').attr('href', canvas.toDataURL());
                    $('#down_button').attr('download', 'myjobdeer.png');
                    var html_canvas = canvas.toDataURL();
                    console.log("html_canvas=",html_canvas)
                    $timeout(function () {
                        $scope.shareQuanImg = html_canvas;
                        $scope.showLoading = false;
                        $scope.showMyCanvas = false;
                        $scope.showQuanShare = true;
                    },0);
                }
            });
        },500);
    }

    //点击关闭分享朋友圈
    $scope.closeShareQuan = function () {
        $(".share-poster-result-dialog .dialog-content").removeClass("bounceInUpAni").addClass("bounceOutUpAni");
        $timeout(function () {
            $scope.showQuanShare = false;
            $(".share-poster-result-dialog .dialog-content").removeClass("bounceOutUpAni").addClass("bounceInUpAni");
        },800);
    }

    //获取微信相关信息*******************************************************************************//
    var currUrl = $location.absUrl().split('#')[0];
    var appId = "wx8a4d94b157c3d0d7";//prd:wx287d1a87770f6a7a
    $http({
        url: '/getConfigSign.ajax',
        method: 'GET',
        params: {
            'url': encodeURIComponent(currUrl),
            'money': "",
            'openId': "",
            'orderId': "",
            'prepayId': ""
        }
    }).success(function(data, header, config, status) {
        console.log(JSON.stringify(data));
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: appId, // 必填，公众号的唯一标识
            timestamp: data.signParam.timestamp, // 必填，生成签名的时间戳
            nonceStr: data.signParam.noncestr, // 必填，生成签名的随机串
            signature: data.signParam.signature, // 必填，签名，见附录1
            jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
    });

    var code = $location.search()['code'];
    var absurl = $location.absUrl();
    // console.log("absurl:"+absurl);
    // console.log("search:"+JSON.stringify($location.search()));
    // console.log("path:"+$location.path());
    // console.log("url:"+$location.url());
    var code1 = absurl.substring(absurl.indexOf("code=")+5,absurl.indexOf("&state="));
    // console.log("code1:"+code1);
    //保证code是传过来的，正常授权情况下才开始登陆操作
    if(code1 && absurl.indexOf("code=") > 0){
        $http({
            url:'/auth.ajax',
            method:'GET',
            params:{
                'code': code1
            }
        }).success(function(data,header,config,status){
            // console.log("authInfo:"+JSON.stringify(data));
            console.log("token:",data.openid);
            console.log("avatar:",data.headimgurl);
            console.log("nickName:",data.nickname);
            userData ={
                openid: data.openid,
                nickName: data.nickname,
                avatar: data.headimgurl
            };
            $scope.userData = userData;
        }).error(function(data,header,config,status){
            //处理响应失败
        });
    }else{
        console.log("你未同意授权");
    }

    wx.ready(function() {
        var shareUrl = "http://wx.winhc.cn/xuanchuan/index.html";
        wx.onMenuShareTimeline({
            title: '达康书记早些给这建议，人民的名义就只有24集了！', // 分享标题
            desc: '大风场的股权问题就不让陈老这么费心了！', // 分享描述
            link: shareUrl, // 分享链接
            imgUrl: 'http://wx.winhc.cn/xuanchuan/img/dakang.png', // 分享图标
            success: function() {
                // 用户确认分享后执行的回调函数
                console.log("分享成功");
            },
            cancel: function() {
                // 用户取消分享后执行的回调函数
                console.log("分享失败");
            }
        });
        //
        wx.onMenuShareAppMessage({
            title: '达康书记早些给这建议，人民的名义就只有24集了！', // 分享标题
            desc: '大风场的股权问题就不让陈老这么费心了！', // 分享描述
            link: shareUrl, // 分享链接
            imgUrl: 'http://wx.winhc.cn/xuanchuan/img/dakang.png', // 分享图标
            success: function() {
                // 用户确认分享后执行的回调函数
                console.log("分享成功");
            },
            cancel: function() {
                // 用户取消分享后执行的回调函数
                console.log("分享失败");
            }
        });

    });
    wx.error(function(res){
        // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
        console.log("微信执行config返回错误信息",res);
    });
    //获取微信相关信息结束**************************************************************************************//

    //启动加载微信适配插件
    var loader = new WxMoment.Loader();
    loader.start();
    new WxMoment.OrientationTip();
    //获取屏幕高度
    $scope.wrapperStyle = {
        "height": window.innerHeight + "px"
    }


    // audio.pause(); 

    // if (ystemJudge() == "IOS") {
    //     if (isWeiXin()) {
    //         audio.play();
    //     } else {
    //     }
    // } else {
    //     audio.play();
    // }

    //*******************************************首页控制器开始*********************************************//
    //点击显示游戏规则
    $scope.showRuleDiv = function () {
        $scope.showGameRuleDiv = true;
    }

    //点击关闭游戏规则
    $scope.closeGameRule = function () {
        $(".globalGameRule .rule_bg").removeClass("bounceInUpAni").addClass("bounceOutUpAni");
        $timeout(function () {
            $scope.showGameRuleDiv = false;
            $(".globalGameRule .rule_bg").removeClass("bounceOutUpAni").addClass("bounceInUpAni");
        },800);
    }

    //点击显示回答问题界面
    $scope.showQuestionPage = function () {
        if(isWeiXin()){
            $scope.showHomePage = false;
            $scope.showQuestionPage = true;
            queryQuestions()
        }else{
            $scope.showTipWeiXinEnv = true;
        }
    }

    //点击关闭提示微信环境界面
    $scope.closeTipWeiXinEnv = function () {
        $scope.showTipWeiXinEnv = false;
    }

    //*******************************************首页控制器结束*********************************************//
    //公共变量
    var userTime;

    //游戏开始**********************************************************************************************//
    $scope.loser=false;
    $scope.showErr5=false;
    $scope.question='';
    $scope.questionTip='';
    $scope.trueNum=0;
    var questions=[],winhcList=[],nowIndex=0,trueAns='',questionId=[];
    var m = 3;
    var s = 0;
    var settime;
    function showtime(){
        if(s==0){
            m = m -1;
            s = 60
        }
        s = s-1;
        document.getElementById('time_min').innerHTML = (m+'').length===2?m:'0'+m;
        document.getElementById('time_sec').innerHTML = (s+'').length===2?s:'0'+s;
        if(m==0&&s==0){
            $timeout(function () {
                $scope.loser=true;
            })
            clearInterval(settime);
            return;
        }
    }

    function queryQuestions() {
        $.ajax({
            url: requestUrl+"/queryQuestions",
            type: "GET",
            success: function(res){
                console.log(JSON.parse(res.body));
                questions=JSON.parse(res.body).normalList;
                winhcList=JSON.parse(res.body).winhcList;
                var length=0;
                for(var i=0;i<questions.length;i++){
                    length=JSON.parse(questions[i].content).answer.split(',')[0].length>length?JSON.parse(questions[i].content).answer.split(',')[0].length:length;
                    length=JSON.parse(questions[i].content).answer.split(',')[1].length>length?JSON.parse(questions[i].content).answer.split(',')[1].length:length;
                    length=JSON.parse(questions[i].content).answer.split(',')[2].length>length?JSON.parse(questions[i].content).answer.split(',')[2].length:length;
                    length=JSON.parse(questions[i].content).answer.split(',')[3].length>length?JSON.parse(questions[i].content).answer.split(',')[3].length:length;
                }
                console.log(length)
                clearInterval(settime);
                showtime();
                settime= setInterval(function(){
                    showtime();
                },1000);
                getQustion()
            },
            error: function(res){
                console.log(res)
            }
        });
    }

    function getQustion() {
        $timeout(function () {
            $scope.question='';
            $scope.questionTip='';
            questionId.push(questions[nowIndex].id)
            $scope.classAns1='';
            $scope.classAns2='';
            $scope.classAns3='';
            $scope.classAns4='';
            if(questions[nowIndex].answer==='A'){
                trueAns=JSON.parse(questions[nowIndex].content).answer.split(',')[0]
                $scope.classAns1='red'
            }else if(questions[nowIndex].answer==='B'){
                trueAns=JSON.parse(questions[nowIndex].content).answer.split(',')[1]
                $scope.classAns2='red'
            }else if(questions[nowIndex].answer==='C'){
                trueAns=JSON.parse(questions[nowIndex].content).answer.split(',')[2]
                $scope.classAns3='red'
            }else if(questions[nowIndex].answer==='D'){
                trueAns=JSON.parse(questions[nowIndex].content).answer.split(',')[3]
                $scope.classAns4='red'
            }
            var allQustion=JSON.parse(questions[nowIndex].content).question
            if(allQustion.indexOf('（')!=-1){
                $scope.question=allQustion.split('（')[0];
                $scope.questionTip='（'+allQustion.split('（')[1];
            }else {
                $scope.question=allQustion;
            }
            $scope.answer1=JSON.parse(questions[nowIndex].content).answer.split(',')[0];
            $scope.answer2=JSON.parse(questions[nowIndex].content).answer.split(',')[1];
            $scope.answer3=JSON.parse(questions[nowIndex].content).answer.split(',')[2];
            $scope.answer4=JSON.parse(questions[nowIndex].content).answer.split(',')[3];
        })
    }

    $scope.checkAns=function (index,an) {
        if(an===trueAns){
            $scope['classAns'+index]='conSuc';
            $scope.trueNum=$scope.trueNum+1;
            if($scope.trueNum>=10){
                clearInterval(settime);
                userTime=(3-m)*60+(60-s);
                answer10();
                return
            }
        }else {
            $scope['classAns'+index]='conErr';
            $scope.showErr5=true;
            if(s-5<=0&&m==0){
                $scope.loser=true;
                clearInterval(settime);
                return
            }else {
                if(s-5<0){
                    s=60+(s-5);
                    m=m-1;
                }else {
                    s=s-5;
                }
            }
        }
        $timeout(function () {
            if($scope.trueNum==5||$scope.trueNum==9){
                questions.splice(nowIndex+1,0,winhcList[0]);
                winhcList.shift()
            }
            nowIndex++;
            $scope.showErr5=false;
            $scope['classAns'+index]='';
            getQustion()
        },300)
    };

    $scope.again=function () {
        $scope.loser=false;
        $scope.showErr5=false;
        $scope.question='';
        $scope.questionTip='';
        $scope.trueNum=0;
        questions=[];
        winhcList=[];
        nowIndex=0;
        trueAns='';
        questionId=[];
        m = 3;
        s = 0;
        queryQuestions()
    };
    //点击时间结束
    $scope.closeTimeOver = function () {
        $scope.loser=false;
        $scope.showErr5=false;
        $scope.question='';
        $scope.questionTip='';
        $scope.trueNum=0;
        questions=[];
        winhcList=[];
        nowIndex=0;
        trueAns='';
        questionId=[];
        m = 3;
        s = 0;
        $scope.showQuestionPage = false;
        $scope.showHomePage = true;
        getHttpData();
    }

    function answer10() {
        $http({
            url:requestUrl+"/answerQuestions",
            method:'POST',
            data:{
                "avatarUrl": userData.avatar,
                "nickName": userData.nickName,
                "openId": userData.openid,
                questionIds:questionId.toString(),
                answerTime:userTime
            }
        }).success(function(ret){
            console.log(ret)
            if(ret.isSuccess=='T'){
                document.querySelector('#results_lever').innerHTML=getLevel(userTime)[0];
                document.querySelector('#results_des').innerHTML=getLevel(userTime)[1];
                $timeout(function () {
                    $scope.showResultsPage = true;
                    $scope.showQuestionPage = false;
                    $scope.rankNow = ret.body;
                },0);
            }
        }).error(function(ret){
            //处理响应失败
            console.log(ret);
        });
    }
    //游戏结束**********************************************************************************************//
    //结果页面**********************************************************************************************//

    //点击去朋友全界面
    $scope.showShareQuanPage = function () {
        $scope.sharePyQuanPage = true;
        $scope.showResultsPage = false;
        document.querySelector('#share_lever').innerHTML=getLevel(userTime)[0];
        document.querySelector('#share_des').innerHTML=getLevel(userTime)[1];
        $scope.createPic();
    }

    //点击显示关注界面
    $scope.showgAttentionPage = function () {
        $scope.showGlobalAttention = true;
        $timeout(function () {
            $scope.isShowAmi = true;
        },500);
    }

    //点击关闭显示关注界面
    $scope.closeGuanZhu = function () {
        $scope.isShowAmi = false;
        $timeout(function () {
            $scope.showGlobalAttention = false;
        },500);
    }

    function getLevel(userTime) {
        var lever='',des='';
        if(userTime>=0 && userTime<36){
            lever='灯谜王者';
            des='灯谜界的王者，<br/>荣耀于天地，<br/>请收下我们的膝盖！';
        }else if(userTime>=36 && userTime<72){
            lever='灯谜宗师';
            des='众所敬仰，堪称灯谜界宗师的人物，<br/>您离顶峰只有一步之遥，突破极限吧！';
        }else if(userTime>=72 && userTime<108){
            lever='灯谜大师';
            des='知识渊博，灯谜界造诣颇深，<br/>大师大师再研究研究，挑战一下吧！';
        }else if(userTime>=108 && userTime<144){
            lever='灯谜智者';
            des='您在灯谜界智慧过人，<br/>知者不惑说的就是您啊，<br/>再加把劲，超越自我吧！';
        }else if(userTime>=144){
            lever='灯谜小萌新';
            des='作为灯谜界的新手，萌萌的您，<br/>还可以有更好的成绩，继续加油！<br/>稳定发挥，您能赢的！';
        }
        return [lever,des]
    }

    //结果页面结束**********************************************************************************************//

    //分享到朋友圈页面开始******************************************************************************************//
//    $scope.createPic();


    //分享到朋友圈页结束******************************************************************************************//


    function getHttpData() {
        $http({
            url:requestUrl+'/userRanking',
            method:'GET',
            params:{
                "openId": userData.openid,
                "pageNum": "1",
                "pageSize": "10"
            }
        }).success(function(ret,header,config,status){
            // console.log("服务端返回："+JSON.stringify(ret));
            var rankingList = JSON.parse(ret.body).rankingList;
            // console.log(rankingList)
            $timeout(function () {
                $scope.rankingList = rankingList;
            },0);
        }).error(function(ret,header,config,status){
            //处理响应失败
            console.log("服务端失败返回："+JSON.stringify(ret));
        });
    }

    function isWeiXin() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger') {
            return true;
        } else {
            return false;
        }
    }

    function ystemJudge() {
        var systemFlag = "";
        var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        if (isAndroid) {
            systemFlag = 'Android';
        } else if (isiOS) {
            systemFlag = 'IOS';
        }
        return systemFlag;
    }
});
app.config(['$routeProvider', function($routeProvider) {
    $routeProvider
    // .when('/',{template:'这是首页页面'})
    // .when('/computers',{template:'这是电脑分类页面'})
    // .when('/printers',{template:'这是打印机页面'})
    // .otherwise({redirectTo:'/'});
}]);

app.filter('yhcfilter', function() {
    return function(input) {
        var array = [];

        return array;
    }
});
</script>

</html>
